﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace DataLoad.iContact.WinClient
{
    public class ContactCollection : List<DLContact>
    {
        public ContactCollection() : base() { }

        public ContactCollection(IEnumerable<DLContact> collection) : base(collection) { }

        public DLContact FindBySelfUri(string selfUri)
        {
            foreach (DLContact contact in this)
            {
                if (contact.Contact.SelfUri.Content == selfUri)
                {
                    return contact;
                }
            }

            return null;
        }



        /*public void SaveToFile(string fileName)
        {
            XmlDocument doc = new XmlDocument();

            XmlElement root = doc.CreateElement("contacts");
            XmlAttribute lastUpdate = doc.CreateAttribute("lastUpdate");
            lastUpdate.Value = DateTime.Now.ToString("yyyy-MM-dd");
            root.Attributes.Append(lastUpdate);

            foreach (DLContact contact in this)
            {
                contact.AddToNode(root);
            }

            doc.Save(fileName);
        }

        public void LoadFromFile(string fileName)
        {

        }*/
    }
}
